package com.app.teaware.bean;

import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.Locale;

import my.MathUtils;

public class GoodsWorks extends BasisBean {

    /**
     * let data = {
     *        'bfs': 4,//1工单、2领料、3退料、4入库
     *        'gna': $('#gna').val(),//货品名称
     *        'gno': $('#gno').val(),//货品编码
     *        'gnu': $('#gnu').val(),//数量
     *        'gun': $('#gun').val(),//单价
     *        'gsp': $('#gsp').val(),//货品规格
     *        'gun': $('#gun').val(),//货品单位
     *        'gwt': $('#gwt').val(),//重量
     *        'wms': $('#wms').val(),//库位
     *        'rfid': $('#rfid').val(),//箱码
     *        'mdt': $('#tdt').val(),//收茶时间
     *       }
     */
    private static final long serialVersionUID = 1L;


    public String getBfs() {
        return bfs;
    }

    public void setBfs(String bfs) {
        this.bfs = bfs;
    }

    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }

    public String getGid() {
        return gid;
    }

    public void setGid(String gid) {
        this.gid = gid;
    }

    public String getGna() {
        return gna;
    }

    public void setGna(String gna) {
        this.gna = gna;
    }

    public String getGno() {
        return gno;
    }

    public void setGno(String gno) {
        this.gno = gno;
    }


    public void autoSetGsp(String unit,String dsn){
        if(dsn.equals("1")){
            this.gsp = getGnu()+unit+"/"+getGun();
        }else {
            this.gsp = MathUtils.multiply(getGwt(),"2")+"斤"+"/"+getGun();
        }
    }

    public String getGsp() {
        return gsp;
    }


    public void setGsp(String gsp) {
        this.gsp = gsp;
    }

    public String getGun() {
        return gun;
    }

    public void setGun(String gun) {
        this.gun = gun;
    }



    public String getMdt() {
        return mdt;
    }

    public void setMdt(String mdt) {
        this.mdt = mdt;
    }

    public String getMid() {
        return mid;
    }

    public void setMid(String mid) {
        this.mid = mid;
    }

    public String getRfid() {
        return rfid;
    }

    public void setRfid(String rfid) {
        this.rfid = rfid;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getWms() {
        return wms;
    }

    public void setWms(String wms) {
        this.wms = wms;
    }

    public String getWno() {
        return wno;
    }

    public void setWno(String wno) {
        this.wno = wno;
    }

    public String getGnu() {
        return gnu;
    }

    public void setGnu(String gnu) {
        this.gnu = gnu;
    }

    public void autoSetGwt(String weight) {
//        String a = MathUtils.multiply(weight,getGnu());
//        String b = MathUtils.div(a,"1000");
        setGwt(MathUtils.div(MathUtils.multiply(weight,getGnu()),"1000") );
    }

    public String getGwt() {
        return gwt;
    }

    public void setGwt(String gwt) {
        this.gwt = gwt;
    }

    public String getGwtp() {
        return gwtp;
    }

    public void setGwtp(String gwtp) {
        this.gwtp = gwtp;
    }

    public String getBwf() {
        return bwf;
    }
    public void setBwf(String bwf) {
        this.bwf = bwf;
    }

    public String getLoc() {
        return loc;
    }

    public void setLoc(String loc) {
        this.loc = loc;
    }
    public String getTid() {
        return tid;
    }

    public void setTid(String tid) {
        this.tid = tid;
    }


    private String bfs;     //1工单/2领料/3退料/4入库
    private String cid;     //上道工艺id
    private String gid;     //货品id
    private String gna;     //货品名称
    private String gno;     //货品编码
    private String gnu;     //包装数量
    private String gsp;     //货品规格
    private String gun;     //整件单位
    private String gwt;     //整件重量
    private String mdt;     //日期
    private String mid;     //主表key
    private String rfid;    //纸箱rfid编码
    private String sid;     //子表key
    private String wms;     //库位码
    private String wno;     //单号
    private String fsn = "1";   //  默认就好



    private String gcd;     //旧编码
    private String gwtp;    //货品重量
    private String bwf;     //纸箱重量  //对应的旧接口字段：wbx


    private String loc;     //楼层
    private String tid;     //货品资料的sid


    public String getGunp() {
        return gunp;
    }

    public void setGunp(String gunp) {
        this.gunp = gunp;
    }
    public String getFsn() {
        return fsn;
    }

    public void setFsn(String fsn) {
        this.fsn = fsn;
    }

    //要提交的
    private String gunp;     //最小单位


    public boolean isShowPart() {
        return isShowPart;
    }

    public void setShowPart(boolean showPart) {
        isShowPart = showPart;
    }

    private boolean isShowPart = false;

    public String getGcd() {
        if(TextUtils.isEmpty(gcd)){
            return "无旧编码";
        }
        return gcd;
    }

    public void setGcd(String gcd) {
        this.gcd = gcd;
    }


    @JSONField(serialize = false)
    public boolean isEmpty(){
        if(TextUtils.isEmpty(gna) && TextUtils.isEmpty(gsp)){
            return true;
        }else {
            return false;
        }
    }

}
